﻿/** layuiAdmin.std-v1.2.1 LPPL License By http://www.layui.com/admin/ */
layui.define(['index','laytpl','element', 'pkc','format'], function (e) {
    var setter = layui.setter;
    var laytpl = layui.laytpl;
    var layer = layui.layer;
    var element = layui.element;
    var format = layui.format;
    var $ = layui.$;
    var pkc = layui.pkc;
    var loginData = layui.data(setter.tableName);  
    if (loginData == null || loginData["data"] == undefined || loginData["data"] == null || loginData["data"][0]["value"] == undefined || loginData["data"][0]["value"] == null) {
        window.location.href = "login.html";
    }
    var LoginName = loginData["data"][0]["value"];
    
    // 获取菜单
    var form = {        
        // 退出登录
        logOut: function(){
            window.localStorage.clear();
            window.location.href = "login.html";
            // var data = {};
            // data["Token"] = Token;
            // data["LoginName"] = LoginName;
            // data["Nonstr"] = format.fm.randomWord(true, 10, 20);
            // data["Signstr"] = md5("Token=" + data["Token"] + "Nonstr=" + data["Nonstr"] + "LoginName=" + data["LoginName"]);
            // return pkc.http.SendPost(
            // data,
            // "Quit",
            //     function (ret) {
            //         if (ret) {
            //             ret = JSON.parse(ret);
            //             if (ret !== null && ret.Status === "1") {
            //                 //success
            //                 window.location.href = "login.html";
            //             } else {
            //                 layer.alert("网络异常.请稍后再试！");
            //             }
            //         }
            //     },
            //     function (res) {
            //         layer.alert("网络异常.请稍后再试！");
            //         // layer.closeAll("loading");
            //     }
            // );
        },
        // 初始化控件事件
        initevt: function(){                      
            $("#logout").on("click", function(){
                form.logOut();
            })
        },
        // 界面初始化
        init: function(){
            this.initevt();
            $("#loginname").html(loginData["data"][0]["value"]);
        }
        
    };    

    e("indexPage", {
        init: () => {
            form.init();
        }
    });
});